package com.atguigu.day1;

/**
 * JUC小口诀
 * 1.高内聚低耦合，线程操作资源类
 * 高内聚，资源类自身携带对外提供的业务方法，对外暴露，这个就是业务方法Method
 * Lambda口诀
 * 1.拷贝小括号，写死右箭头，落地大括号
 */
public class SaleMain {
    public static void main(String[] args) {

        SaleTicket saleTicket = new SaleTicket();

        //匿名内部类
        /*for (int i = 0; i < 51; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    saleTicket.buyTicket();
                }
            }, "A").start();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    saleTicket.buyTicket();
                }
            }, "B").start();

            new Thread(new Runnable() {
                @Override
                public void run() {
                    saleTicket.buyTicket();
                }
            }, "C").start();
        }*/

        //lambda表达式
            new Thread(() -> {
                for (int i = 0; i < 51; i++) {
                    saleTicket.buyTicket();
                }},"A").start();
            new Thread(() -> {
                for (int i = 0; i < 51; i++) {
                    saleTicket.buyTicket();
                }},"B").start();
            new Thread(() -> {
                for (int i = 0; i < 51; i++) {
                    saleTicket.buyTicket();
                }},"C").start();

    }

}
